<template>
  <div class="dashboard-editor-container">
    <el-card class="chart-card">
      <template #header>
        <div class="chart-header">
          <span>折线图数据可视化</span>
        </div>
      </template>

      <panel-group @handleSetLineChartData="handleSetLineChartData" />

      <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
        <line-chart :chart-data="lineChartData" />
      </el-row>

      <el-row :gutter="32">
        <el-col :span="24">
          <div class="chart-description">
            <h3>折线图说明</h3>
            <p>折线图是一种用于显示数据随时间或其他连续变量变化趋势的图表。通过连接数据点形成折线，可以清晰地展示数据的上升、下降和波动情况。</p>
            <p>在本系统中，折线图主要用于展示访问量、消息量、购买量等指标随时间的变化趋势，帮助用户了解业务发展的动态。</p>
          </div>
        </el-col>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import PanelGroup from '@/views/dashboard/PanelGroup'
import LineChart from '@/views/dashboard/LineChart'

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}

export default {
  name: 'LineChartView',
  components: {
    PanelGroup,
    LineChart
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: calc(100vh - 60px);
}

.chart-card {
  margin-bottom: 20px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.chart-header {
  font-size: 18px;
  font-weight: bold;
  color: #1f2937;
  display: flex;
  align-items: center;
}

.chart-description {
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 4px;
  margin-top: 20px;

  h3 {
    margin-top: 0;
    color: #333;
    font-size: 16px;
    margin-bottom: 15px;
  }

  p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: #666;
  }
}

@media (max-width: 768px) {
  .dashboard-editor-container {
    padding: 10px;
  }
  
  .chart-header {
    font-size: 16px;
  }
}
</style>